package com.sky.mapper;

import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /**
     * 根据菜品id查询套餐
     * @param id 菜品id
     * @return 套餐集合
     */
    @Select("select * from setmeal_dish where dish_id = #{id}")
    List<SetmealDish> selectByDishId(Long id);

    /**
     * 添加套餐内菜品信息
     * @param setmealDish setmealDish
     */
    @Insert("insert into setmeal_dish (setmeal_id, dish_id, name, price, copies) " +
            "VALUES (#{setmealId},#{dishId},#{name},#{price},#{copies})")
    void insert(SetmealDish setmealDish);

    /**
     * 根据套餐id删除相关的菜品信息
     * @param id 套餐id
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{id}")
    void deleteBySetMealId(Long id);
}
